//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Validation Application Block
//===============================================================================

using Microsoft.Practices.EnterpriseLibrary.Validation.Configuration.Design.ValidatorNodes;
using Microsoft.Practices.EnterpriseLibrary.Validation.Configuration;
using EntLibContrib.Validation.Configuration.Design.Properties;

namespace EntLibContrib.Validation.Configuration.Design.Nodes
{
	/// <summary>
	/// Respresents the designtime configuration node for an <see cref="CollectionCountValidatorData"/>.
	/// </summary>
	public class CollectionCountValidatorNode : RangeValidatorNodeBase<int>
	{
		#region Construction
		/// <summary>
		/// Creates an instance of <see cref="CollectionCountValidatorNode"/> based on default values.
		/// </summary>
		public CollectionCountValidatorNode()
			: this(new CollectionCountValidatorData(Resources.CollectionCountValidatorNodeName))
		{
		}

		/// <summary>
		/// Creates an instance of <see cref="CollectionCountValidatorData"/> based on runtime configuration data.
		/// </summary>
		/// <param name="validatorData">The corresponding runtime configuration data.</param>
		public CollectionCountValidatorNode(CollectionCountValidatorData validatorData)
			: base(validatorData)
		{
		}
		#endregion

		#region Public Methods
		/// <summary>
		/// Returns the runtime configuration data that is represented by this node.
		/// </summary>
		/// <returns>
		/// An instance of <see cref="CollectionCountValidatorData"/> that can be persisted to a configuration file.
		/// </returns>
		public override ValidatorData CreateValidatorData()
		{
			CollectionCountValidatorData validatorData = new CollectionCountValidatorData(Name);
			SetValueValidatorBaseProperties(validatorData);
			SetRangeValidatorBaseProperties(validatorData);

			return validatorData;
		}
		#endregion
	}
}
